<script type="text/javascript">
	
$(function() {
		   
	$("#formularios").css("height","700px");
	
	jQuery("#DisciplinasGrid").jqGrid({
			url:'actions/ajaxListarDisciplinas.php',
			editurl:'actions/disciplinasAction.php',
            datatype:'json',
            mtype:'GET',
            jsonReader:
				{'repeatitems':false},
            pager:'#DisciplinasPagerGrid',
            rowNum:20,
            rowList:
				[20,30,40,50],
            sortable:true,
            viewrecords:true,
            gridview:true,
            autowidth:false,
            height:370,
            width:780,
            shrinkToFit:true,
            forceFit:true,
            hidegrid:false,
            sortname:'id_disciplina',
            sortorder:'asc',
			caption: "Disciplinas",
            colModel:[
                {label:'Código',width:30,align:'center',name:'id'},
				{label:'Disciplina',width:70,align:'left',name:'nome',editable:true,editrules:{required:true}}
            ] 
        });
	jQuery("#DisciplinasGrid").jqGrid('navGrid', '#DisciplinasPagerGrid', {del:true,add:true,edit:true,search:false,refresh:true} );
	
	
	$("#btnCadDisciplinas").click(function(){
		jQuery("#DisciplinasGrid").jqGrid('editGridRow',"new",{height:200,width:400,reloadAfterSubmit:false});
	});
	
	
	$("#btnEditDisciplinas").click(function(){
		var gr = jQuery("#DisciplinasGrid").jqGrid('getGridParam','selrow');
		if( gr != null ) jQuery("#DisciplinasGrid").jqGrid('editGridRow',gr,{height:200,width:400,reloadAfterSubmit:false});
		else alert("Selecione um Registro");
	});
	
	
	$("#btnDelDisciplinas").click(function(){
		var gr = jQuery("#DisciplinasGrid").jqGrid('getGridParam','selrow');
		if( gr != null ) jQuery("#DisciplinasGrid").jqGrid('delGridRow',gr,{reloadAfterSubmit:false});
		else alert("Selecione um Registro");
	});
	
});

</script>
    
<div id="formularios">

<fieldset style="height:600px;width:800px;padding:2px;">

    <legend>
        <img src="images/topoPaginas/Icon_Disciplinas_Menu.png"  width="90" height="90"/>
    </legend>
    
    
    <div id="btnSairForms">
        <a href="/?pg=home_escola" title="Sair" style="border:0;">
            <img src="images/btnOutros/btnSairForms.png"/>
        </a>
    </div>
    <div style="position:relative;left:10px;"> 
    
        <input type="button" id="btnCadDisciplinas" name="btnCadDisciplinas" value="Cadastrar"/>
        <input type="button" id="btnEditDisciplinas" name="btnEditDisciplinas" value="Editar"/>
        <input type="button" id="btnDelDisciplinas" name="btnDelDisciplinas" value="Excluir"/>
        
        <br /><br />
    
        <table id="DisciplinasGrid" ></table>
        <div id="DisciplinasPagerGrid"></div>    
        
    </div>
</fieldset>


</div>

